package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.domain.vo.PageListVo;
import com.ruoyi.system.service.impl.HotspotPlatformServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotspotPlatform;
import com.ruoyi.system.service.IHotspotPlatformService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 热点平台Controller
 * 
 * @author ruoyi
 * @date 2022-01-20
 */
@RestController
@RequestMapping("/paas/hotspotplatform")
public class HotspotPlatformController extends BaseController
{
    @Autowired
    private IHotspotPlatformService hotspotPlatformService;

    /**
     * 查询热点平台列表，分页
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:listpaging')")
    @GetMapping("/getAllPlatformAndDataPaging")
    @ApiOperation("热点平台及热点数据查询，分页")
    public AjaxResult getAllPlatformAndDataPaging(@RequestBody PageListVo pageListVo, HotspotPlatform hotspotPlatform)
    {
//        startPage();
        PageHelper.startPage(pageListVo.getCurrentPage(), pageListVo.getPageSize());
        List<HotspotPlatform> list = hotspotPlatformService.selectHotspotPlatformList(hotspotPlatform);
        PageInfo pageInfo = new PageInfo(list);
        return AjaxResult.success(pageInfo);
    }

    /**
     * 查询热点平台列表，全部查询
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:list')")
    @GetMapping("/getAllPlatformAndData")
    @ApiOperation("热点平台及热点数据查询，全部查询")
    public AjaxResult getAllPlatformAndData(@RequestBody HotspotPlatform hotspotPlatform)
    {
        List<HotspotPlatform> list = hotspotPlatformService.selectHotspotPlatformList(hotspotPlatform);
        return AjaxResult.success(list);
    }

    /**
     * 导出热点平台列表
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:export')")
    @Log(title = "热点平台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotspotPlatform hotspotPlatform)
    {
        List<HotspotPlatform> list = hotspotPlatformService.selectHotspotPlatformList(hotspotPlatform);
        ExcelUtil<HotspotPlatform> util = new ExcelUtil<HotspotPlatform>(HotspotPlatform.class);
        util.exportExcel(response, list, "热点平台数据");
    }

    /**
     * 获取热点平台详细信息
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:query')")
    @GetMapping(value = "/getPlatformDetail/{platformId}")
    public AjaxResult getPlatformDetail(@PathVariable("platformId") String platformId)
    {
        return AjaxResult.success(hotspotPlatformService.selectHotspotPlatformByPlatformId(platformId));
    }

    /**
     * 新增热点平台
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:add')")
    @Log(title = "热点平台", businessType = BusinessType.INSERT)
    @PostMapping("addPlatformData")
    @ApiOperation("热点平台添加")
    public AjaxResult addPlatformData(@RequestBody HotspotPlatform hotspotPlatform)
    {
        return toAjax(hotspotPlatformService.insertHotspotPlatform(hotspotPlatform));
    }

    /**
     * 修改热点平台
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:edit')")
    @Log(title = "热点平台", businessType = BusinessType.UPDATE)
    @PutMapping("editPlatformData")
    public AjaxResult editPlatformData(@RequestBody HotspotPlatform hotspotPlatform)
    {
        return toAjax(hotspotPlatformService.updateHotspotPlatform(hotspotPlatform));
    }

    /**
     * 删除热点平台
     */
    @PreAuthorize("@ss.hasPermi('paas:hotportplatform:remove')")
    @Log(title = "热点平台", businessType = BusinessType.DELETE)
	@DeleteMapping("/removePlatform/{platformIds}")
    public AjaxResult removePlatform(@PathVariable String[] platformIds)
    {
        return toAjax(hotspotPlatformService.deleteHotspotPlatformByPlatformIds(platformIds));
    }
}
